<%@ Page Title="Sys_AdminInfo List" Language="C#" AutoEventWireup="true" CodeBehind="Sys_AdminInfoList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Sys_AdminInfoList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Sys_AdminInfo, "Sys_AdminInfo", "Sys_AdminInfo") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <form class="form-inline">
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>：</label>
                        <input type="email" id="MemberAccount" maxlength="45" name="MemberAccount" class="form-control" placeholder="<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>">
                    </div>
                    <button type="button" id="btnQuery" name="btnQuery" class="btn btn-default btn-ar btn-primary">
                        <i class="fa fa-search "></i>
                        <%: R(LanguageModule.M_Common, "Query") %>
                    </button>
                </form>
                <div class="form-group"></div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Sys/Sys_AdminInfoItem.aspx')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit"></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o"></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                        <a href="#" class="btn btn-info" id="btnChangePassword"><i class="fa fa-edit"></i>
                            <%: R(LanguageModule.M_Common, "ChangePassword","修改密码") %></a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Sys/Handlers/Sys_AdminInfoHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    d.MemberAccount = $('#MemberAccount').val();
                }
            },
            "columns": [
                     { "data": 'RowIndex', "title": "#" },
                    { "data": 'MemberAccount', "title": "<%: R(LanguageModule.Sys_AdminInfo, "MemberAccount", "会员帐号") %>" },
                    { "data": 'RoleName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "RoleName", "所属角色") %>" },
                    { "data": 'FirstName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "FirstName", "姓") %>" },
                    { "data": 'LastName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "LastName", "名") %>" },
                    { "data": 'Sex', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Sex", "性别") %>", render: fSex1 },
                    { "data": 'Email', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Email", "Email") %>" },
                    { "data": 'MobileNo', "title": "<%: R(LanguageModule.Sys_AdminInfo, "MobileNo", "手机号") %>" },
                    { "data": 'Memo', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Memo", "备注") %>" },
                    { "data": 'Status', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Status", "状态") %>", render: fStatus },
                    { "data": 'Creator', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Creator", "创建人") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Sys_AdminInfo, "CreateTime", "创建时间") %>" },
                    { "data": 'IsModify', "title": "<%: R(LanguageModule.Sys_AdminInfo, "IsModify", "是否可修改") %>", render: fYesNo },
                    { "data": 'HKCreateTime', "title": "<%: R(LanguageModule.Sys_AdminInfo, "HKCreateTime", "HKCreateTime") %>" },
            ],
            "sScrollX":200,
        });

        //delete selected row
        $('#btnDelete').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                if (!dt.row('.selected').data().IsModify) {
                    $(".alert > .content").html("<%: R(LanguageModule.M_Common, "Unmodifiable","该数据无法修改，请重新选择！") %>");
                    $(".alert").show();
                    return false;
                }
                jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm") %>", function () {
                    //console.log(dt.row('.selected').data());
                    $.post("Sys/Handlers/Sys_AdminInfoHandler.ashx?type=delete<%: WebHelper.Get("st") %>", { MemberAccount: dt.row('.selected').data().MemberAccount }, function (data) {
                        if (data) {
                            if (data.isSuccess) {
                                dt.ajax.reload();
                                $.gritter.add({
                                    title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                    text: data.message,
                                    class_name: 'gritter-success'
                                });

                                $('#table tbody tr.selected').remove();
                            }
                            else {
                                $(".alert > .content").html(data.message ? data.message : "<%: R(LanguageModule.M_Common, "Unmodifiable","该数据无法修改，请重新选择！") %>");
                                $(".alert").show();
                            }
                        }
                    }, "json");
                });
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

        //delete selected row
        $('#btnEdit').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                if (!dt.row('.selected').data().IsModify) {
                    $(".alert > .content").html("<%: R(LanguageModule.M_Common, "Unmodifiable","该数据无法修改，请重新选择！") %>");
                    $(".alert").show();
                    return false;
                }
                loadPage("Sys/Sys_AdminInfoItem.aspx?MemberAccount=" + dt.row('.selected').data().MemberAccount);
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });
        $('#btnChangePassword').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                if (!dt.row('.selected').data().IsModify) {
                    $(".alert > .content").html("<%: R(LanguageModule.M_Common, "Unmodifiable","该数据无法修改，请重新选择！") %>");
                    $(".alert").show();
                    return false;
                }
                loadPage("Sys/Sys_AdminPassword.aspx?MemberAccount=" + dt.row('.selected').data().MemberAccount);
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });
        $('#btnQuery').click(function () {
            dt.ajax.reload();
        });
    });
    function fSex1(value, row) {
        return value ? '<span style="color:green"><%: R(LanguageModule.Sys_AdminInfo, "male", "男") %></span>' : '<span style="color:red"><%=R(LanguageModule.Sys_AdminInfo, "Female", "女") %></span>';
    }
</script>
